Computer Science Gate 2017 Set 1 Questions



Ques 1Aptitude

Research in the workplace reveals that people work for many reasons _________.

a) money beside
b) beside money
c) money besides
d) besides money


d is the correct answer.




Ques 2Aptitude

Find the smallest number y such that y*162 is a perfect cube.

a) 24
b) 27
c) 32
d) 36


d is the correct answer.




Ques 3Aptitude

Arun, Gulab, Neel and Shweta must choose one shirt each from a pile of four shirts coloured red, pink, blue and white respectively. Arun dislikes the colour red and Shweta dislikes the colour white. Gulab and Neel like all the colours. In how many different ways can they choose the shirts so that no one has a shirt with a colour he or she dislikes?

a) 21
b) 18
c) 16
d) 14


d is the correct answer.




Ques 4Aptitude

The expression [ (x + y) - |x - y| ] / 2 is equal to___

a) 1
b) the minimum of x and y
c) the maximum of x and y
d) none of the above


Mathematics is the correct answer.




Ques 5Aptitude

"The hold of the nationalist imagination on our colonial past is such that
anything inadequately or improperly natinalist is just not history"


Which of the following statements best reflects the author's opinion?

a) Nationalists are highly imaginative.
b) Nationalists are highly imaginative.
c) Our colonial past never happened.
d) Our colonial past never happened.


English Grammar is the correct answer.




Ques 6Aptitude

Six people are seated around a circular table. There are at least two men and two women. There are at least three right-handed persons. Every woman has a left-handed person to her immediate right. None of the women are right-handed. The number of women at the table is

a) 2
b) 3
c) 4
d) Can not be determined


a is the correct answer.




Ques 7Aptitude

After Rajendra Chola returned from his voyage to Indonesia, he ______ to visit the temple in Tanjavur.

a) was wishing
b) is wishing
c) wished
d) had wished


c is the correct answer.




Ques 8Aptitude

The probability that a k-digit number does NOT contain the digits 0, 5 or 9 is__

a) 0.3k
b) 0.6k
c) 0.7k
d) 0.9k


c is the correct answer.




Ques 9Aptitude

Rahul, Murali, Srinivas and Arul are seated around a square table. Rahul is sitting to the left of Murali. Srinivas is sitting to the right of Arul. Which of the following pairs are seated opposite each other ?

a) Rahul and Murali
b) Srinivas and Arul
c) Srinivas and Murali
d) Srinivas and Rahul


d is the correct answer.




Ques 10Automata

Consider the following grammar:

stmt -> if expr then else expr; stmt | ε
expr -> term relop term | term
term -> id | number
id -> a | b | c
number -> [0-9]


where relop is a relational operate (e.g < >, ….), ε refers to the empty statement, and if ,then, else are terminals. Consider a program P following the above grammar containing ten if terminals. The number of control flows paths in P is ____________. For example, the program

if e1 then
    e2
else
    e3

has 2 control flow paths, e1 -> e2 and e1 -> e3


a is the correct answer.




Ques 11Automata

Consider the language L given by the regular expression (a + b)*b(a +b) over the alphabet {a, b}. The smallest number of states needed in a deterministic finite-state automaton (DFA) accepting L is ______.


4 is the correct answer.




Ques 12Automata

Let A and B be infinite alphabets and let # be a symbol outside both A and B. Let f be a total functional from A* to B* .We say f is computable if there exists a Turning machine M which given an input x in A*, always halts with f(x) on its tape. Let Lf denotes the language {x#f(x)|x∈A*}. Which of the following statements is true?

a) f if computable if and only if Lf is recursive.
b) f if computable if and only if Lf is recursive enumerable.
c) if f is computable then Lf is recursive, but not conversely.
d) if f is computable then Lf is recursively enumerable, but not conversely.


a is the correct answer.




Ques 13Automata

Consider the following languages over the alphabet ∑= {a,b,c}.
Let L1 ={anbncm | m, n >= 0 } and
L2 = {ambncn| m, n >= 0}.

Which of the following are context-free languages ?
I. L1 ∪ L2
II. L1 ∩ L2

a) I only
b) II only
c) I and II
d) Neither I nor II


a is the correct answer.




Ques 14Automata

If G is grammar with productions

S → SaS | aSb | bSa | SS | ∈


where S is the start variable, then which one of the following is not generated by G?

a) abab
b) aaab
c) abbaa
d) babba


CFG is the correct answer.




Ques 15Automata

Consider the following grammar over the alphabet {a,b,c} given below, S and T are non-terminals.

G1: S-->aSb|T
T--> cT|∈
G2: S-->bSa|T
T--> cT|∈

The language L1(G1) ∩ L2(G2).

a) Finite
b) Non-finite but regular
c) Context-free but not regular
d) Recursive but not context-free


b is the correct answer.




Ques 16Automata

Consider the following context-free grammar over the alphabet ∑ = {a, b, c} with S as the start symbol:

S → abScT | abcT
T → bT | b


Which of the following represents the language generated by the above grammar?

a) {(ab)n(cb)n | n >= 1 }
b) {(abncbm1cbm2...cbmn | n, m1, m2, ....., mn >= 1 }
c) {(ab)n(cbm)n | n >= 1 }
d) {(ab)n(cbn)m | m, n >= 1 }


b is the correct answer.




Ques 17Automata

Consider the following grammar

P→xQRS
Q→yz|z
R→ w|∈
S→y

Which is FOLLOW(Q)?

a) {R}
b) {w}
c) {w, y}
d) {w, ∉}


FIRST and FOLLOW is the correct answer.




Ques 18C

The output of executing the following C program is ________.

# include<stdio.h>
int total(int v)
{
    static int count = 0;
    while (v) {
    count += v & 1;
    v >>= 1;
    }
    return count;
}
void main()
{
    static int x = 0;
    int i = 5;
    for (; i> 0; i--) {
        x = x + total(i);
    }
    printf (“%dn”, x) ;
}


a is the correct answer.




Ques 19C

Consider the following C program.

#include<stdio.h>
#include<string.h>
void printlength (char *s, char *t)
{
    unsigned int c = 0;
    int len = ((strlen (s) - strlen (t)) > c) ? strlen (s) : strlen (t);
    printf("%dn", len);
}

void main()
{
    char *x = "abc";
    char *y = "defgh";
    printlength(x, y);
}


Recall that strlen is defined in string.h as returning a value of type size_t, which is an unsigned int . The output of the program is _________.


3 is the correct answer.




Ques 20C

Consider the following two functions
void fun1(int n){
    if(n == 0) return;
      printf(“%d”, n);
    fun2(n-2);
    printf(“%d”, n);
}

void fun2(int n){
    if(n == 0) return;
      printf(“%d”, n);
      fun1(++n);
      printf(“%d”, n);
}

The output printed when fun1 (5) is called is

a) 53423122233445
b) 53423120112233
c) 53423122132435
d) 53423120213243


C Programming is the correct answer.




Ques 21C

Consider the C functions foo and bar given below:

int foo(int val)
{
    int x = 0;
    while (val > 0)
    {
        x = x + foo(val--);
    }
    return val;
}
int bar(int val)
{
    int x = 0;
    while (val > 0)
    {
        x = x + bar(val-1);
        return val;
}
}


Invocations of foo(3) and bar(3) will result in:

a) Return of 6 and 6 respectively.
b) Infinite loop and abnormal termination respectively.
c) Abnomal termination and infinite loop respectively.
d) Both terminating abnormally.


C Programming is the correct answer.




Ques 22C

Consider the C code fragment given below.

typedef struct node
{
    int data;
    node* next ;
} node;
void join(node* m, node* n)
{
    node* p = n;
    while (p->next != NULL)
    {
        p = p->next;
    }
    p–>next = m;
}

Assuming that m and n point to valid NULL- terminated linked lists, invocation of join will

a) append list m to the end of list n for all inputs
b) either cause a null pointer dereference or append list m to the end of list n
c) cause a null pointer dereference for all inputs.
d) append list n to the end of list m for all inputs.


Pointer is the correct answer.




Ques 23C

Consider the C code fragment given below.

typedef struct node
{
    int data;
    node* next ;
} node;
void join(node* m, node* n)
{
    node* p = n;
    while (p->next != NULL)
    {
        p = p->next;
    }
    p–>next = m;
}

Assuming that m and n point to valid NULL- terminated linked lists, invocation of join will

a) append list m to the end of list n for all inputs
b) either cause a null pointer dereference or append list m to the end of list n
c) cause a null pointer dereference for all inputs.
d) append list n to the end of list m for all inputs.


Pointer is the correct answer.




Ques 24C

Consider the following C code:

#include<stdio.h>
int * assignval (int *x, int val)
{
    *x = val;
    return x;
}
int main()
{
    int *x = malloc(sizeof(int));
    if (NULL == x) return;
    x = assignval(x, 0);
    if(x)
    {
        x = (int*) malloc(sizeof (int));
        if (NULL == x) return;
        x = assignval (x, 10);
    }
    printf("%dn", *x);
    free(x);
}


The code suffers from which one of the following problems:

a) compiler error as the return of malloc is not typecast appropriately.
b) compiler error because the comparison should be made as x==NULL and not as shown.
c) compiles successfully but execution may result in dangling pointer.
d) compiles successfully but execution may result in memory leak.


Pointer is the correct answer.




Ques 25C

Consider the C struct defines below:

struct data {
    int marks [100] ;
    char grade;
    int cnumber;
};
struct data student;


The base address of student is available in register R1. The field student grade can be accessed efficiently using

a) Post-increment addressing mode. (R1)+
b) Pre-decrement addressing mode, -(R1)
c) Register direct addressing mode, R1
d) Index addressing mode, X(R1), where X is an offset represented in 2’s complement 16-bit representation.


Structure is the correct answer.




Ques 26COA

Instruction execution in a processor is divided into 5 stages.
Instruction Fetch(IF), Instruction Decode (ID), Operand Fetch(OF), Execute(EX), and Write Back(WB),
These stages take 5,4,20, 10 and 3 nanoseconds (ns) respectively. A pipelined implementation of the processor requires buffering between each pair of consecutive stages with a delay of 2 ns. Two pipelined implementations of the processor are contemplated:

(i) a naïve pipeline implementation (NP) with 5 stages and
(ii) an efficient pipeline (EP) where the OF stage id divided into stages OF1 and OF2 with execution times of 12 ns and 8 ns respectively.


The speedup (correct to two decimals places) achieved by EP over NP in executing 20 independent instructions with no hazards is ________________.


1.50-1.51 is the correct answer.




Ques 27COA

A cache memory unit with capacity of N words and block size of B words is to be designed. If it is designed as direct mapped cache, the length of the TAG field is 10 bits. If the cache unit is now designed as a 16-way set-associative cache, the length of the TAG field is ______ bits.


14 is the correct answer.




Ques 28COA

Consider a 2-way set associative cache with 256 blocks and uses LRU replacement, Initially the cache is empty. Conflict misses are those misses which occur due the contention of multiple blocks for the same cache set. Compulsory misses occur due to first time access to the block. The following sequence of accesses to memory blocks

(0,128,256,128,0,128,256,128,1,129,257,129,1,129,257,129)

is repeated 10 times. The number of conflict misses experienced by the cache is ___________.


76 is the correct answer.




Ques 29COA

Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC- relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further the Offset is always with respect to the address of the next instruction in the program sequence. Consider the following instruction sequence

Instr.No Instruction
i: add R2,R3,R4
i+1 sub R5,R6,R7
i+2 cmp R1,R9,R10
i+3 beq R1,offset


If the target of the branch instruction is i, then the decimal value of the Offest is __________.


-16 is the correct answer.




Ques 30COA

Consider the expression (a-1) * ((( b + c ) / 3 )) + d)). Let X be the minimum number of registers required by an optimal code generation (without any register spill) algorithm for a load/store architecture, in which

(i) only load and store instructions can have memory operands and
(ii) arithmetic instructions can have only register or immediate operands The value of X is ________.


2 is the correct answer.




Ques 31COA

The n-bit fixed-point representation of an unsigned real number X uses f bits for the fraction part. Let i = n - f. The range of decimal values for X in this representation is

a) 2-f
b) 2-f to ( 2i-2-f)
c) 0 to 2-i
d) 0 to (2i - 2-f)


d is the correct answer.




Ques 32Computer Network

The values of parameters for the Stop-and – Wait ARQ protocol are as given below.

Bit rate of the transmission channel = 1Mbps
Propagation delay from sender to receiver = 0.75 ms
Time to process a frame = 0.25ms
Number of bytes in the information frame = 1980
Number of bytes in the acknowledge frame = 20
Number of overhead bytes in the information frame = 20


Assume that there are no transmission errors. Then the transmission efficiency ( expressed in percentage) of the Stop-and – Wait ARQ protocol for the above parameters is _________( correct to 2 decimal place)


a is the correct answer.




Ques 33Computer Network

In a RSA cryptosystem a particular A uses two prime numbers p = 13 and q =17 to generate her public and private keys. If the public key of A is 35. Then the private key of A is ____________.


11 is the correct answer.




Ques 34Computer Network

Consider a TCP client and a TCP server running on two different machines. After completing data transfer, the TCP client calls close to terminate the connection and a FIN segment is sent to the TCP server. Server-side TCP responds by sending an ACK which is received by the client-side TCP. As per the TCP connection state diagram(RFC 793), in which state does the client side TCP connection wait for the FIN from the server-side TCP?

a) LAST-ACK
b) TIME-WAIT
c) FIN-WAIT-1
d) FIN-WAIT-2


d is the correct answer.




Ques 35Computer Network

A computer network uses polynomial over GF(2) for error checking with 8 bits as information bits and uses x3 + x + 1 as the generator polynomial to generate the check bits. In this network, the message 01011011 is transmitted as

a) 01011011010
b) 01011011011
c) 01011011101
d) 01011011100


c is the correct answer.




Ques 36Computer Network

A sender S sends a message m to receiver R, which is digitally signed by S with its private key. In this scenario, one or more of the following security violations can take place.

(I) S can launch a birthday attack to replace m with a fraudulent message.
(II) A third party attacker can launch a birthday attack to replace m with a fraudulent message.
(III) R can launch a birthday attack to replace m with a fraudulent message.

a) (I) only
b) (II) only
c) (I) and (II) only
d) (II) and (III) only


a is the correct answer.




Ques 37DAA

Consider the following table

Algorithms Design Paradigms
(P) Kruskal (i) Divide and Conquer
(Q) Quicksort (ii) Greedy
(R) Floyed Warshall (iii) Dynamic Programming


Match the algorithm to design paradigms they are based on:

a) P-(ii), Q-(iii), R-(i)
b) P-(iii), Q-(i), R-(ii)
c) P-(ii), Q-(i), R-(iii)
d) P-(i), Q-(ii), R-(iii)


Algorithms is the correct answer.




Ques 38DAA

Consider the following functions from positives integers to real numbers

10, √n, n, log2n, 100/n.

The CORRECT arrangement of the above functions in increasing order of asymptotic complexity is:

a) log2n, 100/n,10, √n, n,
b) 100/n,10,log2n, √n, n,
c) 10,100/n, √n,log2n,n
d) 100/n,log2n, 10,√n, n,


Complexity is the correct answer.




Ques 39DAA

Consider the following intermediate program in three address code

p = a - b
q = p * c
p = u * v
q = p+q

Which one of the following corresponds to a static single assignment from the above code?

a) p1 = a - b
q1 =p1 * c
p1= u * v
q1 =p1 + q1

b) p3= a - b
q4= p3* c
p4= u * v
q5 =p4+ q4

c) p1 = a - b
q1=p2 * c
p3= u * v
q2= p4 + q3

d) p1 = a - b
q1= p * c
p2= u * v
q2= p + q


Addressing Mode is the correct answer.




Ques 40Data Structure

Let A be an array of 31 numbers consisting of a sequence of 0’s followed by a sequence of 1’s. The problem is to find the smallest index i such that A[i] is 1 by probing the minimum number of locations in A. The worst case number of probes performed by an optimal algorithm is________.


a is the correct answer.




Ques 41Data Structure

Let T be a tree with 10 vertices. The sum of the degrees of all the vertices in T is _____.


18 is the correct answer.




Ques 42Data Structure

Let G = (V, E) be any connected undirected edge-weighted graph. The weights of the edges in E are positive any distinct. Consider the following statements:

I. Minimum Spanning Tree of G is always unique.
II. Shortest path between any two vertices of G is always unique.

Which of the above statements is/are necessarily true?

a) I only
b) II only
c) both I and II
d) neither I and II


a is the correct answer.




Ques 43Data Structure

Let T be a binary search tree with 15 nodes. The minimum and maximum possible heights of T are:
Note: The height of a tree with a single node is 0.

a) 4 and 15 respectively
b) 3 and 14 respectively
c) 4 and 14 respectively
d) 3 and 15 respectively


Binary Search Tree is the correct answer.




Ques 44DBMS

In a database system, unique time stamps are assigned to each transaction using Lamport’s logical clock. Let TS(T1) and TS(T2) be the time stamps of transactions T1 and T2 respectively. Besides, T1 holds a lock on the resource R, and T2 has requested a conflicting lock on the same resource R. The following algorithm is used to prevent deadlocks in the database assuming that a killed transaction is restarted with the same timestamp.

if TS(T2) <TS(T1) then
    T1 is killed
else
    T2 waits.
.
.
Assume any transactions that is not killed terminates eventually. Which of the following is TRUE about the database system that uses the above algorithm to prevent deadlocks?

a) The database system is both deadlock-free and starvation- free.
b) The database system is deadlock- free, but not starvation-free.
c) The database system is starvation-free but not deadlock- free.
d) The database system is neither deadlock- free nor starvation-free.


a is the correct answer.




Ques 45DBMS

Consider a database that has the relation schemas EMP (EmpId, EmpName, DepId), and DEPT(DeptName, DeptId). Note that the DepId can be permitted to be NULL in the relation EMP. Consider the following queries on the database expressed in tuple relational calculus.

I. {t | ∃ u ∈ EMP (t[EMPName] = u[EmpName] ∧ ∀ v ∈ DEPT (t[DeptId] ≠ DeptId]))}
II. {t | ∃ u ∈ EMP (t[EMPName] = u[EmpName] ∧ ∃ v ∈ DEPT (t[DeptId] ≠ DeptId]))}
III. {t | ∃ u ∈ EMP (t[EMPName] = u[EmpName] ∧ ∃ v ∈ DEPT (t[DeptId] = DeptId]))}

a) I and II only
b) I and III only
c) II and III only
d) I, II, and III


Relational Algebra is the correct answer.




Ques 46DBMS

The following functional dependencies hold true for the relational schema R{V, W, X, Y, Z}:

V→W
VW→X
Y→VX
Y→Z

Which of the following is irreducible equivalent for this set of functional dependencies?

a) V→W
V→X
Y→V
Y→Z

b) V→W
W→X
Y→V
Y→Z

c) V→W
V→X
Y→V
Y→X
Y→Z

d) V→W
W→X
Y→V
Y→X
Y→Z


Functional Dependency is the correct answer.




Ques 47Digital Logic

When two 8-bit numbers A7 ... A0 and B7 ... B0 in 2^^s complement representation (with A0 and B0 as the least significant bits) are added using ripple-carry adder. the sum bits obtained are S7 ... S0 and the carry bits are C7 ... C0. An overflow is said to have occurred if

a) the carry bit C7 is 1
b) all the carry bits (C7, ... , C0 ) are 1
c) (A7 . B7 . S7' + A7' . B7' . S7) is 1
d) (A0 . B0 . S0' + A0' . B0' . S0) is 1


Complements is the correct answer.




Ques 48Discrete Mathematics

Let p, q, and r be the propositions and the expression (p -> q) -> r be a contradiction. Then, the expression (r -> p)-> q is

a) a tautology
b) a contradiction
c) always TRUE when p is FALSE
d) always TRUE when q is TRUE


d is the correct answer.




Ques 49Discrete Mathematics

Consider the first-order logic sentence

F: ∀ x (∃ y R(x,y)).

Assuming non-empty logical domains, which of the sentences below are implied by F?

I. ∃y (∃x R(x,y))
II. ∃y (∀x R(x,y))
III. ∀y (∃x R(x,y))
IV. ∼∃x (∀y R(x,y))

a) II only
b) IV only
c) I and IV only
d) II and III only


Pridicate Calculus is the correct answer.




Ques 50Discrete Mathematics

The statement (¬ p) → (¬ q) is logically equivalent to which of the statements below?


I. p → q
II. q → p
III. (¬ q) ∨ p
IV. (¬ p) ∨ q

a) I only
b) II only
c) I and IV only
d) II and III only


d is the correct answer.




Ques 51Mathematics

The number of integers between 1 and 500 (both inclusive) that are divisible by 3 or 5 or 7 is ______.


271 is the correct answer.




Ques 52Mathematics

Let u and v be two vectors in R2 whose Euclidean norms satisfy ||u|| = 2||v||. What is the value α such that w = u + αv bisects the angle between u and v ?

a) 2
b) 1
c) 1/2
d) -1/2


a is the correct answer.




Ques 53Mathematics

Let X be a Gaussian random variable with mean 0 and variance σ2. Let Y = max(X,0) where max(a,b) is the maximum of a and b. The median of Y is _____.


0 is the correct answer.




Ques 54OS

Consider the following CPU processes with arrival times (in milliseconds) and length of CPU bursts (in milliseconds) as given below:

Process Arrival Time Brust Time
P1 0 7
P2 3 3
P3 5 5
P4 6 2


If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes, then the average waiting time across all processes is _______ milliseconds.


a is the correct answer.




Ques 55OS

Recall that Belady’s anomaly is that the pages-fault rate may increase as the number of allocated frames increases. Now consider the following statements:

S1: Random page replacement algorithm (where a page chosen at random is replaced) suffers from Belady’s anomaly.
S2: LRU page replacement algorithm suffer from Belady’s anomaly .


Which of the following is CORRECT?

a) S1 is true, S2 is true
b) S1 is true, S2 is false
c) S1 is false , S2 is true
d) S1 is false, S2 is false


b is the correct answer.




Ques 56OS

A multithreaded program P executes with x number of threads and uses y number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are non-reentrant, i.e., if a thread holds a lock l, then it cannot re-acquire lock l without releasing it. If a thread is unable to acquire a lock, it blocks until the lock becomes available. The minimum value of x and the minimum value of y together for which execution of P can result in a deadlock are:

a) x = 1, y = 2
b) x = 2, y = 1
c) x = 2, y = 2
d) x = 1, y = 1


d is the correct answer.




Ques 57OS

Threads of a process share

a) global variables but not heap
b) heap but not global variables.
c) neither global variables nor heap.
d) both heap and global variables.


d is the correct answer.